package com.ruoyi;

import com.alibaba.fastjson2.JSONObject;
import com.google.api.client.googleapis.auth.oauth2.GoogleCredential;
import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport;
import com.google.api.client.http.HttpTransport;
import com.google.api.client.json.JsonFactory;
import com.google.api.client.json.gson.GsonFactory;
import com.google.api.services.androidpublisher.AndroidPublisher;
import com.google.api.services.androidpublisher.AndroidPublisherScopes;
import com.google.api.services.androidpublisher.model.ProductPurchase;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;

import java.io.FileInputStream;
import java.util.Collections;

/**
 * 启动程序
 * 
 * @author ruoyi
 */
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
public class OcbvApplication
{

    public static void main(String[] args)
    {

//        try {
//
//            String APPLICATION_NAME = "OraMemo";
//            JsonFactory JSON_FACTORY = GsonFactory.getDefaultInstance();
//
//            String serviceAccountEmail = "fanghua@baiyiholding.com";
//            serviceAccountEmail = "115926086625182640123";
//            String p12KeyFilePath = "D://oramemo-15718ff8e467.p12";
//
//            HttpTransport httpTransport = GoogleNetHttpTransport.newTrustedTransport();
//            GoogleCredential credential = new GoogleCredential.Builder()
//                    .setTransport(httpTransport)
//                    .setJsonFactory(JSON_FACTORY)
//                    .setServiceAccountId(serviceAccountEmail)
//                    .setServiceAccountScopes(Collections.singleton(AndroidPublisherScopes.ANDROIDPUBLISHER))
//                    .setServiceAccountPrivateKeyFromP12File(new FileInputStream(p12KeyFilePath))
//                    .build();
//
//            AndroidPublisher publisher = new AndroidPublisher.Builder(httpTransport, JSON_FACTORY, credential)
//                    .setApplicationName(APPLICATION_NAME)
//                    .build();
//
//
//            String productId = "test1111";
//            String purchaseToken = "mjjlonkbjljfcfofopfbmmei.AO-J1OzhMQb3GLkD-5lYj3oUgGneb-vwz63s9RIkCqEl2jtyGJc2GLZb_FU2rRUvn6CB95kAtPVPkoN6JN_xWKbQA36k6MseVw";
//            String packageName = "com.oramemo.oramemo";
//
////            ProductPurchase purchase = validator.verifyPurchase(packageName, productId, purchaseToken);
//
//            AndroidPublisher.Purchases.Products.Get request =
//                    publisher.purchases().products()
//                            .get(packageName, productId, purchaseToken);
//            ProductPurchase purchase = request.execute();
//
//            System.out.println("Purchase state: " + purchase.getPurchaseState());
//            System.out.println("Purchase time: " + purchase.getPurchaseTimeMillis());
//            System.out.println("验证结果：" + JSONObject.toJSONString(purchase));
//        } catch (Exception e) {
//            e.printStackTrace();
//        }


        System.setProperty("spring.devtools.restart.enabled", "false");
        SpringApplication.run(OcbvApplication.class, args);
        System.out.println("(♥◠‿◠)ﾉﾞ  SmartRing管理系统启动成功   ლ(´ڡ`ლ)ﾞ ");
    }
}
